public class Demo14 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            try {
                Thread.sleep(2000);
                System.out.println("充值电费");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("电费充值完毕");
        });

        Thread t2 = new Thread(() -> {
            try {
                Thread.sleep(2000);
                System.out.println("打开空调");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("空调已开启~~Tina感觉很凉快 :) ");
        });

        System.out.println("Tina想开空调，发现没电了！！");
        Thread.sleep(3000);
        System.out.println("Tina先充了电费");
        t1.start();
        t1.join();      //空调要等电费充完才能打开

        Thread.sleep(2000);
        System.out.println("太好了！！电费充好了~~Tina打开了空调");
        t2.start();
    }
}
